﻿using Microsoft.AspNetCore.Mvc.Rendering;
using System;
using System.Collections.Generic;

namespace Edu.Utilities
{
    public class EnumEx
    {
        internal static List<SelectListItem> ToSelectList<T>() where T : Enum
        {
            var result = new List<SelectListItem>();

            foreach (T item in (T[])Enum.GetValues(typeof(T)))
            {

                result.Add(new SelectListItem()
                {

                    Value = item.ToString(),
                    Text = EnumUtils.StringValueOf(item)
                }); ;
            }

            return result;
        }
    }
}
